/**
 * 链接列表
 */
Vue.component("link-list", {
    template :
        `
        <i-select placeholder="请选择redis链接..." @on-change="redisLinkChange">
            <i-option v-for="o in redisLinks" :value="o.value" :label="o.name">
                <span>{{o.name}}</span>
                <span style="float:right;color:#ccc">{{o.detail}}</span>
            </i-option>
        </i-select>
        `,
    props : ["redisLinks"],
    methods : {
        redisLinkChange : function (value) {
            let that = this, param = new URLSearchParams();
            param.append("token", that.$root.token);
            param.append("host", value);
            that.$Loading.config({
                height: 5
            });
            that.$Loading.start();
            axios.post("./initLink", param).then(function (response) {
                that.$Loading.finish();
                that.$root.clientName = response.data;
            }).catch(function (error) {
                that.$Loading.error();
                that.$Notice.error({
                    title: "redis服务连接失败...",
                    desc: error
                })
            });
        }
    }
});
